<?php

class Costumer_list extends CI_Model {

    function index() {
        $q = $this->db->get('costumer');
        return $q;
    }

    function show($id) {
        $this->db->where('id', $id);
        $q = $this->db->get('costumer');
        return $q;
    }

    function confirm($id, $expire) {
        $data = array(
            'status' => 1,
            'expire' => $expire,
        );
        $this->db->where('id', $id);
        $this->db->update('costumer', $data);
        redirect('costumer_lists/index');
    }
    

    function delete($id) {
        $this->db->where('id', $id);
        $this->db->delete('costumer');
        redirect('costumer_lists/index');
    }

    public function record_count() {
        return $this->db->count_all("costumer");
    }

    function fetch_costumer($limit, $start) {
        $this->db->order_by('id', 'DESC');
        $this->db->limit($limit, $start);
        $query = $this->db->get("costumer");
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $data[] = $row;
            }
            return $data;
        }
        return false;
    }

}

?>
